﻿///----------------------------------------------------------------
/// Copyright (C) 2013-2014 正中科技
/// 版权所有。
///
/// 文件名：TB_TEAM_FILEDAL.cs
/// 文件功能描述：TB_TEAM_FILE数据访问类
///
///
/// 创建标识：曹彬 2014/3/18
///
/// 修改标识：
/// 修改描述：
///
/// 修改标识：
/// 修改描述：
///---------------------------------------------------------------
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using XMK.Tadong.Model;
using XMK.Framework.DataAccess;
using XMK.Utils;

namespace XMK.Tadong.Data
{
    /// <summary>
    /// TB_TEAM_FILE的数据访问类
    /// </summary>
    public class TB_TEAM_FILEDAL 
    {

        #region  构造函数

         /// <summary>
        /// 数据库连接
        /// </summary>
        protected DbProvider dbProvider;
        public TB_TEAM_FILEDAL(DbProvider dbProvider)
        {
            this.dbProvider = dbProvider;
        }

        #endregion  构造函数

        #region  成员方法

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool AddBySql(TB_TEAM_FILEInfo model)
        {
            if (model.SECRET_LVL == null)
                model.SECRET_LVL = "10";
            string strSQL = @" INSERT INTO TB_TEAM_FILE 
					(TEAM_ID,FILE_NAME,FILE_EXT,FILE_ABST,FILE_AUTHOR,KEYW,FILE_CRT_TIME,FILE_SIZE，DOWN_AMOUNT，DEST_OBJ,BIZ_OBJ,SECRET_LVL,LANG_TYPE,FILE_TYPE,SAVE_PATH,USER_ID,STATUS,CREATE_TIME,UPD_TIME,SINGLERECEIPT,PDF_PATH,SWF_PATH,FOLDER_ID,FILE_VERSION) 
					VALUES(:p_TEAM_ID,:p_FILE_NAME,:p_FILE_EXT,:p_FILE_ABST,:p_FILE_AUTHOR,:p_KEYW,:p_FILE_CRT_TIME,:p_FILE_SIZE,:p_DOWN_AMOUNT,:p_DEST_OBJ,:p_BIZ_OBJ,:p_SECRET_LVL,:p_LANG_TYPE,:p_FILE_TYPE,:p_SAVE_PATH,:p_USER_ID,:p_STATUS,:p_CREATE_TIME,:p_UPD_TIME,:p_SINGLERECEIPT,:p_PDF_PATH,:p_SWF_PATH,:p_FOLDER_ID,:p_FILE_VERSION)";

            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                //参数生成
                delegate()
                {
                    return DbCmdHelper.CreateParameters(dbProvider, "TEAM_ID", "FILE_NAME", "FILE_EXT", "FILE_ABST", "FILE_AUTHOR", "KEYW", "FILE_CRT_TIME", "FILE_SIZE", "DOWN_AMOUNT", "DEST_OBJ", "BIZ_OBJ", "SECRET_LVL", "LANG_TYPE", "FILE_TYPE", "SAVE_PATH", "USER_ID", "STATUS", "CREATE_TIME", "UPD_TIME", "SINGLERECEIPT", "PDF_PATH", "SWF_PATH", "FOLDER_ID", "FILE_VERSION").ToArray();
                });
            //参数设值
            cmd.SetParamValues(model.TEAM_ID, model.FILE_NAME, model.FILE_EXT, model.FILE_ABST, model.FILE_AUTHOR, model.KEYW, model.FILE_CRT_TIME, model.FILE_SIZE, model.DOWN_AMOUNT, model.DEST_OBJ, model.BIZ_OBJ, model.SECRET_LVL, model.LANG_TYPE, model.FILE_TYPE, model.SAVE_PATH, model.USER_ID, model.STATUS, model.CREATE_TIME, model.UPD_TIME, model.SINGLERECEIPT, model.PDF_PATH, model.SWF_PATH, model.FOLDER_ID,model.FILE_VERSION);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;
        
        }

        public bool isExist(TB_TEAM_FILEInfo model)
        {
            string team_id = model.TEAM_ID.ToString();
            string file_name = model.FILE_NAME;
            string file_path = model.SAVE_PATH;

            string strSQL = " SELECT COUNT(*) FROM TB_TEAM_FILE WHERE  TEAM_ID = "+team_id+"and FILE_NAME = '"+file_name+"'and SAVE_PATH = '"+file_path+"'";

            StringBuilder strSql = new StringBuilder();
            strSql.Append(strSQL);
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd);

            return (Convert.ToInt16(obj) != 0);
           
        }

        /// <summary>
        /// 判断同一用户，文件夹下是否已有同名文件
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public bool HasFileName(string User_ID,string Team_ID,string File_Name ,string Folder_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT count(*) FROM TB_TEAM_FILE WHERE User_ID = '" + User_ID + "' and Folder_ID='" + Folder_ID + "' and Team_ID='" + Team_ID + "' and File_Name='" + File_Name + "'");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd);

            return (Convert.ToInt16(obj) != 0);


        }

        /// <summary>
        /// 判断同一目录下是否有多个引用
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public bool HasSavePath(string Save_Path)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT count(*) FROM TB_TEAM_FILE WHERE Save_Path = '" + Save_Path + "'");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd);

            return (Convert.ToInt16(obj) > 1);


        }

        public int GetIdByPathName(string team_id, string file_path, string file_name)
        {
            string strSQL = " SELECT FILE_ID FROM TB_TEAM_FILE WHERE  TEAM_ID = " + team_id + "and FILE_NAME = '" + file_name + "'and SAVE_PATH = '" + file_path + "'";

            StringBuilder strSql = new StringBuilder();
            strSql.Append(strSQL);
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd);
            if (obj == null)
                return -1;
            return Convert.ToInt16(obj);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool UpdateBySql(TB_TEAM_FILEInfo model)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET TEAM_ID = :p_TEAM_ID,FILE_NAME = :p_FILE_NAME,FILE_EXT = :p_FILE_EXT,FILE_ABST = :p_FILE_ABST,FILE_AUTHOR = :p_FILE_AUTHOR,KEYW = :p_KEYW,FILE_CRT_TIME = :p_FILE_CRT_TIME,FILE_VERSION = :p_FILE_VERSION,DEST_OBJ = :p_DEST_OBJ,BIZ_OBJ = :p_BIZ_OBJ,SECRET_LVL = :p_SECRET_LVL,LANG_TYPE = :p_LANG_TYPE,FILE_TYPE = :p_FILE_TYPE,SAVE_PATH = :p_SAVE_PATH,USER_ID = :p_USER_ID,STATUS = :p_STATUS,CREATE_TIME = :p_CREATE_TIME,UPD_TIME = :p_UPD_TIME,SINGLERECEIPT = :p_SINGLERECEIPT, PDF_PATH=:p_PDF_PATH, SWF_PATH=:p_SWF_PATH,FOLDER_ID=:p_FOLDER_ID
					WHERE FILE_ID=:p_FILE_ID ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                //参数生成
                delegate()
                {
                    return DbCmdHelper.CreateParameters(dbProvider, "FILE_ID", "TEAM_ID", "FILE_NAME", "FILE_EXT", "FILE_ABST", "FILE_AUTHOR", "KEYW", "FILE_CRT_TIME", "FILE_VERSION", "DEST_OBJ", "BIZ_OBJ", "SECRET_LVL", "LANG_TYPE", "FILE_TYPE", "SAVE_PATH", "USER_ID", "STATUS", "CREATE_TIME", "UPD_TIME", "SINGLERECEIPT", "PDF_PATH", "SWF_PATH", "FOLDER_ID").ToArray();
                });
            //参数设值
            cmd.SetParamValues(model.FILE_ID, model.TEAM_ID, model.FILE_NAME, model.FILE_EXT, model.FILE_ABST, model.FILE_AUTHOR, model.KEYW, model.FILE_CRT_TIME, model.FILE_VERSION, model.DEST_OBJ, model.BIZ_OBJ, model.SECRET_LVL, model.LANG_TYPE, model.FILE_TYPE, model.SAVE_PATH, model.USER_ID, model.STATUS, model.CREATE_TIME, model.UPD_TIME, model.SINGLERECEIPT, model.PDF_PATH, model.SWF_PATH,model.FOLDER_ID);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;
           
        }

        /// <summary>
        /// 审核数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool UpdateDatasBySql(string File_ID,string Folder_ID,string Upd_Time)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET UPD_TIME = to_date('" + Upd_Time + "','yyyy/mm/dd HH24:MI:SS'),status = 1,FOLDER_ID='" + Folder_ID + "'	WHERE FILE_ID in (" + File_ID + ") ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool UpdateBySql(TB_TEAM_FILEInfo model,string Flag)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET TEAM_ID = :p_TEAM_ID,FILE_NAME = :p_FILE_NAME,FILE_EXT = :p_FILE_EXT,FILE_ABST = :p_FILE_ABST,FILE_AUTHOR = :p_FILE_AUTHOR,KEYW = :p_KEYW,FILE_CRT_TIME = :p_FILE_CRT_TIME,FILE_VERSION = :p_FILE_VERSION,FILE_SIZE=:p_FILE_SIZE,DOWN_AMOUNT=:p_DOWN_AMOUNT,DEST_OBJ = :p_DEST_OBJ,BIZ_OBJ = :p_BIZ_OBJ,SECRET_LVL = :p_SECRET_LVL,LANG_TYPE = :p_LANG_TYPE,FILE_TYPE = :p_FILE_TYPE,USER_ID = :p_USER_ID,STATUS = :p_STATUS,CREATE_TIME = :p_CREATE_TIME,UPD_TIME = :p_UPD_TIME,SINGLERECEIPT = :p_SINGLERECEIPT
					WHERE FILE_ID=:p_FILE_ID ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                //参数生成
                delegate()
                {
                    return DbCmdHelper.CreateParameters(dbProvider, "FILE_ID", "TEAM_ID", "FILE_NAME", "FILE_EXT", "FILE_ABST", "FILE_AUTHOR", "KEYW", "FILE_CRT_TIME", "FILE_VERSION", "FILE_SIZE", "DOWN_AMOUNT", "DEST_OBJ", "BIZ_OBJ", "SECRET_LVL", "LANG_TYPE", "FILE_TYPE", "USER_ID", "STATUS", "CREATE_TIME", "UPD_TIME", "SINGLERECEIPT").ToArray();
                });
            //参数设值
            cmd.SetParamValues(model.FILE_ID, model.TEAM_ID, model.FILE_NAME, model.FILE_EXT, model.FILE_ABST, model.FILE_AUTHOR, model.KEYW, model.FILE_CRT_TIME, model.FILE_VERSION, model.FILE_SIZE, model.DOWN_AMOUNT, model.DEST_OBJ, model.BIZ_OBJ, model.SECRET_LVL, model.LANG_TYPE, model.FILE_TYPE, model.USER_ID, model.STATUS, model.CREATE_TIME, model.UPD_TIME, model.SINGLERECEIPT);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }


        /// <summary>
        /// 重新提交
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool AgainDataSubmitBySql(TB_TEAM_FILEInfo model, string Flag)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET FILE_NAME = :p_FILE_NAME,FILE_AUTHOR = :p_FILE_AUTHOR,KEYW = :p_KEYW,FILE_CRT_TIME = :p_FILE_CRT_TIME,DEST_OBJ = :p_DEST_OBJ,BIZ_OBJ = :p_BIZ_OBJ,STATUS = :p_STATUS
					WHERE FILE_ID=:p_FILE_ID ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                //参数生成
                delegate()
                {
                    return DbCmdHelper.CreateParameters(dbProvider, "FILE_ID", "FILE_NAME", "FILE_AUTHOR", "KEYW", "FILE_CRT_TIME", "DEST_OBJ", "BIZ_OBJ","STATUS").ToArray();
                });
            //参数设值
            cmd.SetParamValues(model.FILE_ID, model.FILE_NAME, model.FILE_AUTHOR, model.KEYW, model.FILE_CRT_TIME, model.DEST_OBJ, model.BIZ_OBJ, model.STATUS);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }


        /// <summary>
        /// 重新提交
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool NewAgainDataSubmitBySql(string File_ID)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET STATUS = 0
					WHERE FILE_ID in(" + File_ID + ") ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }

        /// <summary>
        /// 修改源数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool UpDateSourceDataBySql(TB_TEAM_FILEInfo model)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET FILE_NAME = :p_FILE_NAME,FILE_AUTHOR = :p_FILE_AUTHOR,KEYW = :p_KEYW,FILE_CRT_TIME = :p_FILE_CRT_TIME,DEST_OBJ = :p_DEST_OBJ,BIZ_OBJ = :p_BIZ_OBJ,FILE_ABST=:p_FILE_ABST,FILE_EXT=:p_FILE_EXT,LANG_TYPE=:p_LANG_TYPE,FILE_VERSION=:p_FILE_VERSION,SECRET_LVL=:p_SECRET_LVL,SHARED_SCOPE_ID=:p_SHARED_SCOPE_ID
					WHERE FILE_ID=:p_FILE_ID ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                //参数生成
                delegate()
                {
                    return DbCmdHelper.CreateParameters(dbProvider, "FILE_ID", "FILE_NAME", "FILE_AUTHOR", "KEYW", "FILE_CRT_TIME", "DEST_OBJ", "BIZ_OBJ", "FILE_ABST", "FILE_EXT", "LANG_TYPE", "FILE_VERSION", "SECRET_LVL", "SHARED_SCOPE_ID").ToArray();
                });
            //参数设值
            cmd.SetParamValues(model.FILE_ID, model.FILE_NAME, model.FILE_AUTHOR, model.KEYW, model.FILE_CRT_TIME, model.DEST_OBJ, model.BIZ_OBJ, model.FILE_ABST, model.FILE_EXT, model.LANG_TYPE, model.FILE_VERSION, model.SECRET_LVL, model.SHARED_SCOPE_ID);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }


        /// <summary>
        /// 退回数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool BackFileBySql(string SINGLERECEIPT, string FILE_ID)
        {
            string strSQL = @" UPDATE TB_TEAM_FILE 
					SET SINGLERECEIPT = '" + SINGLERECEIPT + "',Status=2 WHERE FILE_ID in (" + FILE_ID + ") ";
            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }


        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="File_ID">文件编号</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool DeleteBySql(string File_ID)
        {
            string strSQL = @" delete from TB_TEAM_FILE where File_ID=" + File_ID + "";

            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;

        }

        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="FileID">文件ID</param>
        /// <returns>文件列表</returns>
        public DataTable GetModelBySql(string FileID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select a.*,d.team_name,e.user_name from tb_team_file a left join tb_team d on a.team_id = d.team_id left join base_userinfo e on a.user_id=e.user_id WHERE a.FILE_ID = ' " + FileID + "'");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }

        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="FileID">文件ID</param>
        /// <returns>文件列表</returns>
        public DataTable GetNewModelBySql(string FileID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select a.*,d.team_name,e.user_name from tb_team_file a left join tb_team d on a.team_id = d.team_id left join base_userinfo e on a.user_id=e.user_id WHERE a.FILE_ID in (" + FileID + ")");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }


        /// <summary>
        /// 获取文档Model
        /// </summary>
        /// <param name="FileID">文件ID</param>
        /// <returns>文件列表</returns>
        public XMKFileExtInfo GetModelByFileId(string FileID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select a.* from tb_team_file a WHERE a.FILE_ID = ' " + FileID + "'");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            return DbManager.GetInfo(cmd,
                delegate(out XMKFileExtInfo model, DataRow row)
                {
                    model = new XMKFileExtInfo
                    {
                        FILE_ID = ParseHelper.Parse<long>(row["FILE_ID"]),
                        FILE_NAME = ParseHelper.Parse<string>(row["FILE_NAME"]),
                        FILE_EXT = ParseHelper.Parse<string>(row["FILE_EXT"]),
                        FILE_CRT_TIME = ParseHelper.Parse<DateTime>(row["FILE_CRT_TIME"]),
                        KEYW = ParseHelper.Parse<string>(row["KEYW"]),
                        UPD_TIME = ParseHelper.Parse<DateTime>(row["UPD_TIME"]),
                        FILE_TYPE = ParseHelper.Parse<string>(row["FILE_TYPE"]),
                        FILE_ABST = ParseHelper.Parse<string>(row["FILE_ABST"]),
                        CREATE_TIME = ParseHelper.Parse<DateTime>(row["CREATE_TIME"]),
                        SAVE_PATH = ParseHelper.Parse<string>(row["SAVE_PATH"]),
                        USER_ID = ParseHelper.Parse<string>(row["USER_ID"]),
                        FILE_AUTHOR = ParseHelper.Parse<string>(row["FILE_AUTHOR"]),
                        FILE_VERSION = ParseHelper.Parse<string>(row["FILE_VERSION"]),
                        FILE_SIZE = ParseHelper.Parse<string>(row["FILE_SIZE"]),
                        DOWN_AMOUNT = ParseHelper.Parse<decimal>(row["DOWN_AMOUNT"]),
                        DEST_OBJ = ParseHelper.Parse<string>(row["DEST_OBJ"]),
                        BIZ_OBJ = ParseHelper.Parse<string>(row["BIZ_OBJ"]),
                        SECRET_LVL = ParseHelper.Parse<string>(row["SECRET_LVL"]),
                        LANG_TYPE = ParseHelper.Parse<string>(row["LANG_TYPE"]),
                        BIZ_OBJ_NAME = ParseHelper.Parse<string>(row["biz_obj"]),
                        DEST_OBJ_NAME = ParseHelper.Parse<string>(row["dest_obj"]),
                        TEAM_ID = ParseHelper.Parse<int>(row["TEAM_ID"]),
                        PDFFilePath = ParseHelper.Parse<string>(row["PDF_PATH"]),
                        SwfFilePath = ParseHelper.Parse<string>(row["SWF_PATH"])
                    };
                });

        }

        /// <summary>
        /// 获取未审核文件
        /// </summary>
        /// <returns>文件列表</returns>
        public DataTable GetUnauditedModelBySql(string Team_ID, string sorttype, string sortdesc, int startNum, int endNum, ref int total)
        {

            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM base_userinfo a right join TB_TEAM_FILE b on a.USER_ID = b.USER_ID  where b.status=0 and b.team_id=" + Team_ID);
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);

            total = Convert.ToInt32(obj);

            StringBuilder strSql = new StringBuilder();
            if (sorttype == "time")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =0 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by TB_TEAM_FILE.CREATE_TIME desc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
                else
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =0 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by TB_TEAM_FILE.CREATE_TIME asc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
            }
            else if (sorttype == "user")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =0 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by base_userinfo.USER_ID desc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
                else
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =0 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by base_userinfo.USER_ID asc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
            }
            
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }

        /// <summary>
        /// 根据课题组ID获得当前课题组未审核文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public DataTable getTeamFileInfoByTeamName(string teamName)
        {
            //获得待审核文件信息
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT a.FILE_ID,a.FILE_NAME,a.UPD_TIME,a.CREATE_TIME,b.TEAM_ID,b.TEAM_NAME FROM TB_TEAM_FILE a  join TB_TEAM b on a.TEAM_ID = b.TEAM_ID where b.TEAM_NAME=" + teamName + "order by a.CREATE_TIME DESC");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;
        }

        /// <summary>
        /// 获取已审核文件
        /// </summary>
        /// <returns>文件列表</returns>
        public DataTable GetAuditedDataBySql(string Team_ID, string sorttype, string sortdesc, int startNum, int endNum, ref int total)
        {
            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where status=1 and team_id=" + Team_ID);
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);

            total = Convert.ToInt32(obj);

            StringBuilder strSql = new StringBuilder();
            if (sorttype == "time")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =1 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by TB_TEAM_FILE.CREATE_TIME desc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
                else
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =1 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by TB_TEAM_FILE.CREATE_TIME asc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
            }
            else if (sorttype == "user")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =1 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by base_userinfo.USER_NAME desc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
                else
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,FILE_ID,FILE_NAME,CREATE_TIME,USER_NAME，UPD_TIME,USER_ID,SAVE_PATH,TEAM_ID from (SELECT TB_TEAM_FILE.FILE_ID,TB_TEAM_FILE.FILE_NAME,TB_TEAM_FILE.CREATE_TIME,TB_TEAM_FILE.UPD_TIME,TB_TEAM_FILE.USER_ID,TB_TEAM_FILE.SAVE_PATH,TB_TEAM_FILE.TEAM_ID,base_userinfo.USER_NAME from TB_TEAM_FILE,base_userinfo where TB_TEAM_FILE.User_Id =base_userinfo.USER_ID and TB_TEAM_FILE.status =1 and TB_TEAM_FILE.team_id=" + Team_ID + "  order by base_userinfo.USER_NAME asc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + "");
                }
            }
            
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }


        /// <summary>
        /// 获取我提交的文件已审核
        /// </summary>
        /// <returns>文件列表</returns>
        public DataTable GetMySubmitModelBySql(string User_ID, string sorttype, string sortdesc, string status, int startNum, int endNum, ref int total)
        {

            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  USER_ID='" + User_ID + "' and status=" + status);
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);

            total = Convert.ToInt32(obj);


            StringBuilder strSql = new StringBuilder();
            if (sorttype == "time")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,file_id,file_name,CREATE_TIME,team_name from(SELECT  a.file_id,a.file_name,a.CREATE_TIME,b.team_name FROM TB_TEAM_FILE a left join TB_TEAM b on a.team_id = b.team_id where a.User_ID='" + User_ID + "'  and a.status="+status+" order by a.CREATE_TIME desc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + " ");
                }
                else
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,file_id,file_name,CREATE_TIME,team_name from(SELECT  a.file_id,a.file_name,a.CREATE_TIME,b.team_name FROM TB_TEAM_FILE a left join TB_TEAM b on a.team_id = b.team_id where a.User_ID='" + User_ID + "'  and a.status=" + status + " order by a.CREATE_TIME asc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + " ");
                }
            }
            else if (sorttype == "space")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,file_id,file_name,CREATE_TIME,team_name from(SELECT  a.file_id,a.file_name,a.CREATE_TIME,b.team_name FROM TB_TEAM_FILE a left join TB_TEAM b on a.team_id = b.team_id where a.User_ID='" + User_ID + "'  and a.status=" + status + " order by b.team_id desc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + " ");
                }
                else
                {
                    strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,file_id,file_name,CREATE_TIME,team_name from(SELECT  a.file_id,a.file_name,a.CREATE_TIME,b.team_name FROM TB_TEAM_FILE a left join TB_TEAM b on a.team_id = b.team_id where a.User_ID='" + User_ID + "'  and a.status=" + status + " order by b.team_id asc)) table_tmp WHERE table_tmp.rowno >  " + startNum.ToString() + "  and table_tmp.rowno <" + endNum.ToString() + " ");
                }
            } 
           
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }


        /// <summary>
        /// 审核数据
        /// </summary>
        /// <param name="FileID">文件编号</param>
        /// <returns>成功返回true，失败返回false</returns>
        public bool AuditDataBySql(string FileID, string newPath)
        {
            string strSQL = @" update TB_TEAM_FILE set STATUS=1,Save_Path ='" + newPath + "' where File_ID=" + FileID;

            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;
        }


        /// <summary>
        /// 审核数据
        /// </summary>
        /// <param name="FileID">文件编号</param>
        /// <returns>成功返回true，失败返回false</returns>
        public bool AuditDataBySql(string FileID)
        {
            string strSQL = @" update TB_TEAM_FILE set STATUS=1 where File_ID=" + FileID;

            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;
        }

        /// <summary>
        /// 批量审核数据
        /// </summary>
        /// <param name="FileID">文件编号</param>
        /// <returns>成功返回true，失败返回false</returns>
        public bool AuditDatasBySql(string FileID)
        {
            string strSQL = @" update TB_TEAM_FILE set STATUS=1 where File_ID in (" + FileID+")";

            bool result = true;

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;
        }

        /// <summary>
        /// 根据课题组ID获得当前课题组共享文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public DataTable getTeamFileyTeamId(string teamId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from tb_team_file  WHERE TEAM_ID=" + teamId + " AND STATUS=0");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;
        }

        /// <summary>
        /// 根据文件名称、文件路径获得当前课题组文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public DataTable getTeamFileyFileNameAndPath(string teamid,string FileName,string Path)
        {
            StringBuilder strSql = new StringBuilder();
            //strSql.Append("select a.*,b.obj_name as bus_obj_name,c.obj_name as target_obj_name,a.file_size from tb_team_file a left join tb_tree_bus b on a.biz_obj = b.obj_id left join tb_tree_target c on a.dest_obj =c.obj_id WHERE a.FILE_NAME='" + FileName + "' AND a.SAVE_PATH='" + Path + "' and a.TEAM_ID= " + teamid);
            strSql.Append("select a.* from tb_team_file a WHERE a.FILE_NAME='" + FileName + "' AND a.SAVE_PATH='" + Path + "' and a.TEAM_ID= " + teamid);
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;
        }

        /// <summary>
        /// 课题组共享文件到项目库
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public bool ShareFileToXmk(TB_TEAM_FILE_SHAREInfo fileShareObj)
        {

            bool result = true;
            string sql = @"insert into TB_TEAM_FILE_SHARE(SHARE_OBJ_ID , SHARE_OBJ_TYPE ,FILE_ID  ,CREATE_TIME  , UPD_TIME)
                                             values(:p_SHARE_OBJ_ID,:p_SHARE_OBJ_TYPE,:p_FILE_ID,:p_CREATE_TIME, :p_UPD_TIME)";

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, sql,
                //参数生成
                delegate()
                {
                    return DbCmdHelper.CreateParameters(dbProvider, "SHARE_OBJ_ID", "SHARE_OBJ_TYPE", "FILE_ID", "CREATE_TIME", "UPD_TIME").ToArray();
                });
            //参数设值
            cmd.SetParamValues(fileShareObj.SHARE_OBJ_ID, fileShareObj.SHARE_OBJ_TYPE, fileShareObj.FILE_ID, fileShareObj.CREATE_TIME, fileShareObj.UPD_TIME);
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            if (back == 0)
                result = false;

            return result;
        }

        /// <summary>
        /// 修改关键词和摘要信息
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回true,失败返回false</returns>
        public bool UpDateInfoBySql(TB_TEAM_FILEInfo model, string types)
        {
            bool result = true;
            string strSQL = "";
            if (types.Equals("ZYXX"))
            {
                strSQL = @" UPDATE TB_TEAM_FILE 
					set FILE_ABST=:p_FILE_ABST
					WHERE FILE_ID=:p_FILE_ID ";


                //新建一个数据库操作帮助类
                DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                    //参数生成
                    delegate()
                    {
                        return DbCmdHelper.CreateParameters(dbProvider, "FILE_ID", "FILE_ABST").ToArray();
                    });
                //参数设值
                cmd.SetParamValues(model.FILE_ID, model.FILE_ABST);
                cmd.DbCmdInfo.CommandType = CommandType.Text;
                int back = DbManager.ExecNonQuery(cmd);
                if (back == 0)
                    result = false;


            }
            else if (types.Equals("GJC"))
            {
                strSQL = @" UPDATE TB_TEAM_FILE 
					set KEYW = :p_KEYW
					WHERE FILE_ID=:p_FILE_ID ";


                //新建一个数据库操作帮助类
                DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSQL,
                    //参数生成
                    delegate()
                    {
                        return DbCmdHelper.CreateParameters(dbProvider, "FILE_ID", "KEYW").ToArray();
                    });
                //参数设值
                cmd.SetParamValues(model.FILE_ID, model.KEYW);
                cmd.DbCmdInfo.CommandType = CommandType.Text;
                int back = DbManager.ExecNonQuery(cmd);
                if (back == 0)
                    result = false;


            }
            return result;

        }

        /// <summary>
        /// 获取文件总数
        /// </summary>
        /// <param name="folder_id">文件夹ID</param>
        /// <param name="keyword">关键词</param>
        /// <returns></returns>
        public int GetCountByDestObjByKeyWord(string folder_id, string keyword)
        {
            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  FOLDER_ID = '" + folder_id + "'  and  FILE_NAME like '%" + keyword + "%'");
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);
            return Convert.ToInt32(obj);
        }

        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="DestObjId">文件所在目标ID</param>
        /// <returns>文件列表</returns>
        public int GetCountByDestObj(string folder_id)
        {
            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  FOLDER_ID = '" + folder_id + "' ");
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);
            return Convert.ToInt32(obj);
        }

        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="DestObjId">文件所在目标ID</param>
        /// <returns>文件列表</returns>
        public DataTable GetModelByDestObjAndType(string op,string folder_id, int startNum, int endNum, string TEAM_ID, string USER_ID, ref int total)
        {

            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "'and is_del=0");
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);
            total = Convert.ToInt32(obj);


            StringBuilder strSql = new StringBuilder();
            if (op.Equals("FILE_SIZE"))
            {
                //strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,BIZ_OBJ,FILE_SIZE FROM TB_PERSON_FILE WHERE FOLDER_ID = '" + folder_id + "' and  USER_ID='" + ID + "') table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString() + " order by tokb(file_size) desc");
                //strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE,FILE_EXT FROM TB_TEAM_FILE WHERE FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "') table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString() + " order by tokb(file_size)  desc");
                strSql.Append("select * from(SELECT  ROWNUM AS rowno, FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE,FILE_EXT from (SELECT  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE,FILE_EXT FROM TB_TEAM_FILE WHERE FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "'and is_del=0  and status!=0 order by tokb(file_size) desc))table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString());
            }
            else
            {
                //strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE,FILE_EXT FROM TB_TEAM_FILE WHERE FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "') table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString() + " order by " + op + " desc");
                strSql.Append("select * from(SELECT ROWNUM AS rowno,  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE,FILE_EXT FROM (SELECT  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE,FILE_EXT  FROM TB_TEAM_FILE WHERE FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "' and is_del=0  and status!=0 order by " + op + " desc) )table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString());
            }
             DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }

        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="DestObjId">文件所在目标ID</param>
        /// <returns>文件列表</returns>
        public DataTable GetModelByDestObjAndKeyWord(string folder_id, int startNum, int endNum, string TEAM_ID, string USER_ID, string keyword, ref int total)
        {

            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "' and FILE_NAME like '%" + keyword + "%'");
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);
            total = Convert.ToInt32(obj);


            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE FROM TB_TEAM_FILE WHERE FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "' and is_del=0 and status!=0 and FILE_NAME like '%" + keyword + "%') table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString() + " order by Create_time desc");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }

        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="DestObjId">文件所在目标ID</param>
        /// <returns>文件列表</returns>
        public DataTable GetModelByDestObj(string folder_id, int startNum, int endNum,string TEAM_ID,string USER_ID, ref int total)
        {

            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "'");
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);
            total = Convert.ToInt32(obj);


            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM (SELECT  ROWNUM AS rowno,  FILE_NAME,FILE_ID,CREATE_TIME,UPD_TIME,DEST_OBJ,FILE_SIZE FROM TB_TEAM_FILE WHERE FOLDER_ID = '" + folder_id + "' and TEAM_ID='" + TEAM_ID + "' and is_del=0 and status!=0) table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString() + " order by Create_time desc");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

        }

        /// <summary>
        /// 根据文件ID获得文件
        /// </summary>
        /// <param name="teamId"></param>
        /// <returns></returns>
        public DataTable GetTeamFileBySql(string File_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from tb_team_file  WHERE File_ID=" + File_ID + "");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;
        }

     

        //数据库是否有文件
        public bool IsMoreThanOne(string File_ID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT count(*) FROM tb_team_file WHERE File_ID = '" + File_ID + "'");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd);

            return (Convert.ToInt16(obj) > 1);
        }

        //根据文件ID将文件移动到回收站
        public bool RemoveToRecycleBySql(string File_ID)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update tb_team_file set is_del=1,RECYCLE_DATE=to_date('" + System.DateTime.Now.Date.ToString("yyyy-MM-dd") + "','yyyy-MM-dd') where file_id in (" + File_ID + ")");
                DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());
                cmd.DbCmdInfo.CommandType = CommandType.Text;
                return DbManager.ExecNonQuery(cmd) > 0;

            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }
            return false;
        }


        /// <summary>
        /// 获取文件列表
        /// </summary>
        /// <param name="FileID">文件IDs</param>
        /// <returns>文件列表</returns>
        public DataTable GetModelListBySql(string FileID)
        {
            //获得待审核文件信息
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from tb_team_file WHERE FILE_ID in(" + FileID + ")");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="fileId">ids</param>
        /// <returns></returns>
        public bool DeleteIN(string fileId)
        {
            bool result = true;


            string sql = @"delete from  tb_team_file  where FILE_ID in (" + fileId + ") ";

            //新建一个数据库操作帮助类
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, sql);
            
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            int back = DbManager.ExecNonQuery(cmd);
            return result;
        }

        //根据文件ID将文件从回收站移回空间
        public bool RecycleToSpaceBySql(string File_ID)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update tb_team_file set is_del=0 where file_id in (" + File_ID + ")");
                DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());
                cmd.DbCmdInfo.CommandType = CommandType.Text;
                return DbManager.ExecNonQuery(cmd) > 0;

            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }
            return false;
        }
        //获取课题组空间同名文件最大版本号
        public decimal GetMaxFileTeam(string fileName, string Team_id)
        {

            try
            {

                //获得待审核文件信息
                StringBuilder strSql = new StringBuilder();
                strSql.Append("select max(FILE_VERSION) FROM TB_TEAM_FILE where FILE_NAME='" + fileName + "' and Team_ID='" + Team_id + "'");
                DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());

                cmd.DbCmdInfo.CommandType = CommandType.Text;
                DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
                if (ds != null)
                {
                    return ParseHelper.Parse<decimal>(ds.Rows[0][0]);
                }

            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }
            return 0;
        }
        /// <summary>
        /// 获取回收站信息
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <returns>结果集</returns>
        public DataTable GetRecycleDataBySql(string teamid, string sorttype, string sortdesc, int startNum, int endNum, ref int total)
        {
            StringBuilder strSql_ = new StringBuilder();
            strSql_.Append("SELECT count(*) FROM TB_TEAM_FILE where  TEAM_ID='" + teamid + "' and is_del=1");
            DbCmdHelper cmd_ = new DbCmdHelper(dbProvider, strSql_.ToString());
            cmd_.DbCmdInfo.CommandType = CommandType.Text;
            object obj = DbManager.ExecScalar(cmd_);

            total = Convert.ToInt32(obj);
            StringBuilder strSql = new StringBuilder();
            if (sorttype == "time")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append(@"select * from(SELECT  ROWNUM AS rowno,file_id,file_name,FILE_SIZE,RECYCLE_DATE from (select file_id,file_name,FILE_SIZE,RECYCLE_DATE from tb_team_file  where is_del=1  and team_id='" + teamid + "' order by Create_time desc) )table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString());
                }
                else
                {
                    strSql.Append(@"select * from(SELECT  ROWNUM AS rowno,file_id,file_name,FILE_SIZE,RECYCLE_DATE from (select file_id,file_name,FILE_SIZE,RECYCLE_DATE from tb_team_file  where is_del=1  and team_id='" + teamid + "' order by Create_time asc) )table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString());
                }
            }
            else if (sorttype == "size")
            {
                if (sortdesc == "desc")
                {
                    strSql.Append(@"select * from(SELECT  ROWNUM AS rowno,file_id,file_name,FILE_SIZE,RECYCLE_DATE from (select file_id,file_name,FILE_SIZE,RECYCLE_DATE from tb_team_file  where is_del=1  and team_id='" + teamid + "' order by tokb(FILE_SIZE） desc) )table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString());
                }
                else
                {
                    strSql.Append(@"select * from(SELECT  ROWNUM AS rowno,file_id,file_name,FILE_SIZE,RECYCLE_DATE from (select file_id,file_name,FILE_SIZE,RECYCLE_DATE from tb_team_file  where is_del=1  and team_id='" + teamid + "' order by tokb(FILE_SIZE） asc) )table_tmp WHERE table_tmp.rowno > " + startNum.ToString() + " and table_tmp.rowno <" + endNum.ToString());
                }
            }
           
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, strSql.ToString());
            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;
        }

        #endregion  成员方法

    }
}

